<%@ page language="java" contentType="text/html; charset=UTF-8"
	import="java.util.*,com.sp.model.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新闻</title>
<meta name="keywords" content="新闻" />
<meta name="description" content="新闻" />
<link href="css/index.css" rel="stylesheet" type="text/css" />
<script src="js/jquery.js"></script>
</head>
<body>
  <% 
  int curPage = 1;
  int pageSize = 12;
  if(request.getParameter("curPage")!=null){
  curPage = Integer.valueOf(request.getParameter("curPage"));
  }
  
  %>
  <%
  List<NewsBean> newsList = new ArrayList<NewsBean>();
  String referer = request.getHeader("REFERER")!=null?request.getHeader("REFERER"):"  ";
  if(referer.substring(referer.lastIndexOf("/")+1,Math.min(referer.lastIndexOf("/")+27,referer.length()) ) 
  		.equals("SelectNewsSelectiveServlet")){
  	if(session.getAttribute("newsList")!=null){ 
  	newsList =(List<NewsBean>)session.getAttribute("newsList");  	
  	System.out.println("从session中获取的newsList长度为"+newsList.size());}
  }
  else{
  newsList = new NewsBeanOper().getNews();
  System.out.println("未使用session获取数据");  
  }
  
  
 %>
	<div class="nav">
		<ul>
			<li class="wbg"><a href="index.html">网站后台</a></li>
			<li><a href="" title="">公司概况</a></li>
			<li><a href="news.jsp?tid=0" title="">新闻中心</a></li>
			<li><a href="show.html" title="">产品展示</a></li>
			<li><a href="" title="">成功案例</a></li>
			<li><a href="" title="">专业优势</a></li>
			<li><a href="" title="">资料下载</a></li>
			<li><a href="" title="">人才招聘</a></li>
			<li><a href="" title="">人才中心</a></li>
			<li><a href="" title="">联系我们</a></li>
		</ul>
	</div>
	<div class="banner">
		<img alt="" src="images/banner.jpg" width="950" height="195" />
	</div>
	<div class="all">
		<div class="content">
			<div class="main1">
				<div class="left1">
					<div class="fl">
						<div class="bt2">
							新闻中心<span>NEWS</span>
						</div>
						<div class="TabTitle2">
							<ul class="expmenu">
								<%!
     NTypeOper ntop;
     ArrayList<NTypeBean> al;
     NTypeBean nt;
     int i;
%>
								<%        ntop=new NTypeOper();
    al=ntop.GetTypeList();  
         for(i=0;i<al.size();i++)  
                {  
                    nt=(NTypeBean)al.get(i);  
   %>
								<li>
									<div class="header">
										<a href="SelectNewsSelectiveServlet?newsType=<%=nt.getTid()%>" title=""><%=nt.getTname() %></a>
									</div>
								</li>
								<%} %>

							</ul>
						</div>
					</div>
					<div class="so">
						<div class="bt2">
							快速搜索<span>SEARCH</span>
						</div>
						<div class="soso">
							<form method="get" action="SelectNewsSelectiveServlet">
								<select class="wbyselect"  name="newsType">
									<option value="" name="newsType">所有新闻</option>
									<%
 				ntop=new NTypeOper();
    			al=ntop.GetTypeList();  
                for(i=0;i<al.size();i++)  
                {  
                   nt=(NTypeBean)al.get(i);  
   %>
									<option name="newsType" value="<%=nt.getTid()%>"><%=nt.getTname() %></option>
									<%} %>

								</select> 
								<input type="text" value="-请输入关键字-"
									onfocus="javascript:if(this.value == '-请输入关键字-') this.value = '';"
									onblur="javascript:if(this.value == '') this.value = '-请输入关键字-'; "
									class="wbyinput" name="keywords" />
									
									 <input class="wbybut"
									type="submit" name="wbysearch" value="搜索" />
							</form>
						</div>
					</div>
					<div class="so">
						<div class="bt2">
							联系我们<span>CONTACT</span>
						</div>
						<div class="contact">
							地址：江干区学正街18号******<br /> 电话：*********<br /> 邮箱：********* <br />
							邮编：*********
						</div>
					</div>
				</div>
				<div class="right1">
					<div class="position">
						您当前位置：<a href="" title="">网站首页</a> > <a href="" title="">新闻中心</a>
					</div>
					<div class="news">
						<ul>
							<%if(session.getAttribute("newsList")!=null){
          System.out.println("session的newsList属性存在");
          }; %>
          <%
          for(int temp=(curPage-1)*pageSize;temp<curPage*pageSize&&temp<newsList.size();temp++){
          out.println("<li><span>"+newsList.get(temp).getAddTime()+"</span><a href='showNews.jsp?nid="+newsList.get(temp).getId()+"' title=''>"+newsList.get(temp).getTitle()+"</a></li>");
          }
           %>
							<li><span>2014-02-17</span><a href="show.jsp" title="">环保已成为塑料橡胶行业的发展趋势</a></li>
							<li><span>2014-02-16</span><a href="" title="">国际质量管理和质量保证体系国际</a></li>
							<li><span>2014-02-15</span><a href="" title="">节能及环保已成为塑料橡胶行业的</a></li>
							<li><span>2014-02-14</span><a href="" title="">公司全面国际质量管理和质量保证</a></li>
							<li><span>2014-02-13</span><a href="" title="">管理和质量保证体系国际质量管理</a></li>
							<li><span>2014-02-12</span><a href="" title="">全面实施ISO9000国际质量管理和质量保证体系</a></li>
							<li><span>2014-02-14</span><a href="" title="">公司全面国际质量管理和质量保证</a></li>
							

						</ul>
					</div>
		<div class="pagelist" align="right"> 
        <%
        int pageTemp=1;
        int totalCount = Integer.valueOf((session.getAttribute("pageCount")!=null?session.getAttribute("pageCount"):12).toString());
        int totalPage =(totalCount%pageSize==0)?totalCount/pageSize:totalCount/pageSize+1;       		
        if(curPage==1){
        out.print("<a>上一页&nbsp&nbsp</a>");}
        else{
        out.print("<a href='news.jsp?curPgae="+(curPage-1)+"'>上一页&nbsp&nbsp</a>");}
        
        
        for(pageTemp=1;pageTemp<=totalPage;pageTemp++){
        if(pageTemp==curPage){
        out.print("<span class='current'>"+pageTemp+"&nbsp&nbsp</span>");
        }
        else{
        out.print("<a href='news.jsp?curPage="+pageTemp+"'>"+pageTemp+"&nbsp&nbsp</a>");}
        }
        
        if(curPage==totalPage){
        out.print("<a>下一页&nbsp&nbsp</a>");
        out.print("<a>尾页&nbsp&nbsp</a>");}
        else{
        out.print("<a href='news.jsp?curPgae="+(curPage+1)+"'>下一页&nbsp&nbsp</a>");
        out.print("<a href='news.jsp?curPage="+totalPage+"'>尾页&nbsp&nbsp</a>"); }       
        %>
		</div>
					<div class="ym"></div>
				</div>
			</div>
			<div class="bottom">
				<div class="foot">
					<div class="foot1">
						<div class="fnav">
							<a title="" href="">网站首页</a> | <a title="" href="">服务项目</a> | <a
								title="" href="">联系我们</a> | <a title="" href="">客户留言</a> | <a
								title="" href="">人才招聘</a> | <a title="" href="">联系我们</a>
						</div>
						网址：http://www.xxx.com/&nbsp;&nbsp; 电话：000-00000000&nbsp;&nbsp;
						手机：12345678912&nbsp;&nbsp; E-mail:123@123.com
					</div>
				</div>
			</div>
		</div>
	</div>

</body>

</html>
<script>
$(document).ready(
/* function(){
window.location.href="SelectNewsSelectiveServlet";
} */
/* function (){
var referer = $(document).referer;
alert(referer==null);
if(referer==null){
window.location.href="SelectNewsSelectiveServlet";
}
} */
);
</script>